package repo

import model "micro-oauth/datamodels"

func (s*ServiceImpl)ListPermissionMethod(partnerId uint64)([]*model.Method,error){
	db := s.db
	db.Where("partner_id = ?", partnerId)
	methodList := make([]*model.Method,0)
	err := db.Find(&methodList).Error;if err != nil{
		return nil, err
	}

	return methodList,nil
}

func(s*ServiceImpl) DeletePermissionMethodByService(partnerId,scopeId uint64,serviceName string)error{
	db := s.db.Where("partnerId = ?",partnerId)
	db = db.Where("scope_id = ?",scopeId)
	db = db.Where("service_name = ?",serviceName)

	return db.Delete(&model.Method{}).Error
}